package cn.itcast.mq.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class SpringRabbitListener {

    // 监听接收simple.queue队列消息
    /*@RabbitListener(queues = "simple.queue")
    public void listenSimpleQueue(String msg) {
        System.out.println("消费者接收到simple.queue的消息：【" + msg + "】");
    }*/

    // acknowledge-mode: none # 关闭ack 阅后即焚
    // 模拟一个消息处理异常
    // 消费着确认消息 + 消费失败重试机制 本地重试 + 失败策略
    @RabbitListener(queues = "simple.queue")
    public void listenSimpleQueue2(String msg) {
        System.out.println("消费者接收到simple.queue的消息：【" + msg + "】");
        System.out.println(1/0);
        log.debug("消息处理完成~~~");
    }


}
